//
//  ListCollectionViewCell.m
//  DolphinMusic
//
//  Created by dllo on 15/3/22.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ListCollectionViewCell.h"
//#import "UIImageView+AFNetworking.h"
#import "PrefixHeader.pch"
#import "UIImageView+WebCache.h"

@implementation ListCollectionViewCell

- (void)dealloc
{
    [_blackJianBian release];
    [_list release];
    [_imageView release];
    [_listenImageView release];
    [_listenNumLabel release];
    [_titleLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];
        [_imageView release];
        
        self.blackJianBian = [[UIImageView alloc] init];
        [self.contentView addSubview:self.blackJianBian];
        [_blackJianBian release];
        
        self.listenImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.listenImageView];
        [_listenImageView release];
        
        self.listenNumLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.listenNumLabel];
        [_listenNumLabel release];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
    }
    return self;
}

- (void)setList:(SongList *)list
{
    if (_list != list) {
        [_list release];
        _list = [list retain];
    }
    
    self.imageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 90);
    NSURL *url = [NSURL URLWithString:[self.list.pic stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [self.imageView setImageWithURL:url];
    
    self.blackJianBian.frame = CGRectMake(0, 70, self.contentView.frame.size.width, 20);
    self.blackJianBian.alpha = 0.7;
//    UIImage *image = [UIImage imageNamed:@"blackjianbian.jpeg"];
    UIImage *image = [UIImage imageNamed:@"xiaomajianbian.jpg"];
    image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)];
    self.blackJianBian.image = image;
    
    self.listenImageView.frame = CGRectMake(5, 73, 15, 15);
    self.listenImageView.image = [UIImage imageNamed:@"erji.png"];
    
    self.listenNumLabel.frame = CGRectMake(25, 73, 80, 15);
    self.listenNumLabel.text = self.list.listenum;
    self.listenNumLabel.font = [UIFont systemFontOfSize:16];
    self.listenNumLabel.textColor = [UIColor whiteColor];
    
    self.titleLabel.frame = CGRectMake(0, 95, self.contentView.frame.size.width, 25);
    self.titleLabel.text = self.list.title;
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.titleLabel.numberOfLines = 0;
    [self.titleLabel sizeToFit];
    
}



@end
